typedstream StreamTable HashTable Object [20c] typedstream [1026c] typedstream HashTable Object FirstResponder HeaderClass %%%%i@@ firstnib checkSpelling: alignSelCenter: unscript: pasteFont: runPageLayout: superscript: copyRuler: copyFont: selectAll: pasteRuler: toggleRuler: showGuessPanel: alignSelLeft: paste: performClose: arrangeInFront: subscript: copy: alignSelRight: delete: orderFrontColorPanel: underline: performMiniaturize: SphereControl genericobject_nib infoPanel phiTextDisplayPtr latTextDisplayPtr radiusTextDisplayPtr hideBoxPtr longTextDisplayPtr helpPanel sphereViewPtr sphereDrawerPtr autoRenderPtr thetaTextDisplayPtr shadeBoxPtr getThetaSlider: getRadiusSlider: getPhiSlider: messageSphereDrawer: clickHideBox: clickShadeBox: getLongSlider: getLatSlider: autoRender: loadHelpNib: loadInfoNib: [3713c] typedstream HashTable Object NibData @@@@s Storage {*@@} [6{*@@}] File's Owner CustomObject SphereControl Panel WindowTemplate iiii***@s@ Sphere Help Responder ScrollView ClipView ciifffcfffs [2400c]{\rtf0\ansi{\fonttbl\f1\fnil Times-Roman;\f0\fswiss Helvetica;} \margl40 \margr40 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\f1\b0\i0\ul0\fs28 \ \i\fs48 Overview \b0\i0\fs28 \ I wrote this program as learning example on how to convert a straight-line Unix-C program into a finished NextStep/Objective-C Application. The actual conversion effort turned out to be much easier than I anticipated. \ I had already written a command line program that calculated a sphere and output it as PostScript-code to stdout (sphere [parameter list] > output.ps). I was able to convert this program into a Next App in about 4 hours. \ \i\fs48 IB & Objective-C\ \i0\fs28 \ The first step was to create the main window in Interface Builder -- using sliders and buttons in place of the Unix command-line parameters.\ Next, I subclassed object to create a SphereDrawerObject which contains all of the drawing & shading routines from my original Unix-C code (some functions still need to be turned into methods, but the code works as is). \ I then created a sub-class of view called SphereView and overrode the initFrame: and drawSelf:: methods. The drawSelf:: method messages the SphereDrawerObject which outputs postscript code into the view. Because this happens INSIDE drawSelf:: rather than locking-focus & drawing INTO the instance of SphereView, it makes the print-routine trivial to implement (click&drag from the print menu-button to the view and connect the printPSCode: target method).\ Last (but far from least) I subclassed object to create my controller (SphereControl). All of the program variables are stored in this object and methods to read and write each instance variable are implemented. Also, all of the program controls are routed through this object. \ \i\fs48 The Sphere Program \i0\fs28 \ The light source is fixed in the Z-direction and the program uses lambert's law of cosines to calculate the shading.\ Moving the sliders for theta and phi actually move the eyepoint around the sphere, rather than rotating the sphere (only apparent if shading is turned on).\ Be sure to try low settings on the latitude and longitude sliders (interesting non-spherical shapes are generated by the sphere algorithm). \ \fs36 Special thanks to Tyler Gingrich for helping teach me many of the basics about programming on the NeXT. NXCursor NXImage NXibeam Scroller Control _doScroller: @@@ffs Button ButtonCell ActionCell Helvetica SSphere TextField TextFieldCell Sphere Times-Italic$ &A Conversion Example: C to Objective-C ScrollingText Field2 Field4 {i*@@@} [1{i*@@@}] helpPanel